#pragma once

#include <QVector>
#include <QColor>
#include <boost/shared_ptr.hpp>

//
// IMesh
//

class IMesh {
public:
  typedef boost::shared_ptr<IMesh> SP;

public:
  enum element_type {
    element_none = -1,
    element_point,
    element_vector,
    element_line,
    element_quad,
    element_triangle,
    element_qty
  };

  //
  // IMesh::vector
  //

  struct vector {
    vector(): x(0), y(0), z(0) { }
    vector(qreal x, qreal y, qreal z = 0.0): x(x), y(y), z(z) { }
    union {
      struct {
        qreal x, y, z;
      };
      qreal v[3];
    };
  };

  //
  // IMesh::color
  //

  struct color {
    color(): r(0), g(0), b(0) { }
    color(quint8 r, quint8 g, quint8 b): r(r), g(g), b(b) { }
    union {
      struct {
        quint8 r, g, b;
      };
      quint8 c[3];
    };
    color &operator=(const QColor &col)
    {
      r = col.red();
      g = col.green();
      b = col.blue();
      return *this;
    }
  };

  typedef QVector<vector>  t_container_vertex;
  typedef QVector<color>   t_container_color;
  typedef QVector<quint32> t_container_element;

public:
  virtual ~IMesh() {}

// Vertex
  virtual const t_container_vertex  &get_vertices() const = 0;
  virtual const t_container_color   &get_vertices_colors() const = 0;
// Elements
  virtual const t_container_element &get_elements(element_type) const = 0;
  virtual const t_container_color   &get_elements_colors(element_type) const = 0;
};